checkbutton: Match GtkButton behavior
authorMatthias Clasen <mclasen@redhat.com>
Sat, 19 Jun 2021 20:27:55 +0000 (13:27 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 19 Jun 2021 20:30:31 +0000 (13:30 -0700)
When leaving the widget before releasing the button,
we should not activate the checkbutton, to match the
way GtkButton behaves.

Fixes: #4061
gtk/gtkcheckbutton.c

index b5c2eecab22eb62d0d87e9cd5b4bf435d5e1189e..9860641ac695edc71cba9ee35550a48483113720 100644 (file)
@@ -324,11 +324,14 @@ click_released_cb (GtkGestureClick *gesture,
     return;
 
   gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
-
-  if (priv->action_helper)
-    gtk_action_helper_activate (priv->action_helper);
-  else
-    gtk_check_button_set_active (self, !priv->active);
+  if  (gtk_widget_is_sensitive (widget) &&
+       gtk_widget_contains (widget, x, y))
+    {
+      if (priv->action_helper)
+        gtk_action_helper_activate (priv->action_helper);
+      else
+        gtk_check_button_set_active (self, !priv->active);
+    }
 }
 
 static void